<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
  <title>Title</title>
  <link rel="stylesheet" href="static/bootstrap-3.4.1-dist/css/bootstrap.css">
</head>
<body>
<table class="table table-striped table-bordered table-hover table-condensed">
  <tr>
    <td>ID</td>
    <td>课程名</td>
    <td>学分</td>
    <td>删除</td>
  </tr>
  <c:forEach items="${pageInfo.list}" var="course">
    <tr>
      <td>${course.id}</td>
      <td>${course.name}</td>
      <td>${course.credit}</td>
      <td><a onclick="deleteById(${course.id})" href="javascript:void(0)">删除</a></td>
    </tr>
  </c:forEach>
</table>
<nav aria-label="Page navigation">
  <ul class="pagination">
    <li>
      <a href="#" aria-label="Previous">
        <span aria-hidden="true">&laquo;</span>
      </a>
    </li>
    <c:forEach begin="1" end="${pageInfo.totalPage}" var="i" step="1">
      <c:if test="${i==pageInfo.pageNo}">
        <li class="active"><a href="#">${i}</a></li>
      </c:if>
      <c:if test="${i!=pageInfo.pageNo}">
        <li><a href="/course?method=selectByPage&pageNo=${i}">${i}</a></li>
      </c:if>
    </c:forEach>
    <li>
      <a href="#" aria-label="Next">
        <span aria-hidden="true">&raquo;</span>
      </a>
    </li>
  </ul>
</nav>

<script>
  function deleteById(id) {
    var isDelete = confirm('您确认要删除么？');
    if (isDelete) {
      location.href = '/course?method=deleteById&id=' + id;
    }
  }
</script>

</body>
</html>
